<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <link rel="stylesheet" type="text/css" href="__CSS__/lib/normalize.css" />
    <link rel="stylesheet" type="text/css" href="__CSS__/mui-3.6.1.min.css" />
    <link rel="stylesheet" type="text/css" href="__CSS__/cash.css" />
    <title>提现</title>
</head>

<body>
    <div class="cover" id="cover"></div>
      <!-- 菜单容器 -->

          <div id="bank" class="bank-list">
            <!-- 菜单具体展示内容 -->
            <foreach name="banks" item="vo">
                <div class="rows " data-id="{$vo['bankId']}" onClick="selectBank(this)">{$vo['bankName']}</div>
            </foreach>
        </div>


    <div class="top-bar" onClick="history.back()">
        <div class="return"></div>
        <div class="top-middle">提现</div>
        <div class="top-right"></div>
    </div>
    <div class="rows rows-first">
        <label>可兑换金额：</label>
        <div>&yen;<span id="money">{$list['userMoney']|default=0}</span></div>
    </div>

    <input type="hidden" value="{$list['bizMoney']}" id="Balance" />

    <div class="rows ">
        <label>申请金额：</label>
        <input id="applyPrice" onkeyup="this.value=this.value.replace(/\D/g,'')"  type="number" class="mui-input-clear" placeholder="请输入申请金额">
    </div>



    <div class="rows " id="bankBtn" onClick="showBank()">
        <label>选择银行</label>
        <div id="bankName" class="arrow-right"><div class="right-icon"></div></div>
        <!-- <input type="text" class="mui-input-clear" placeholder="请输入用户名"> -->
    </div>
    <div class="rows ">
        <label>开户支行：</label>
        <input id="cardAccess" type="text" class="mui-input-clear" placeholder="请输入开户支行地址">
    </div>
    <div class="rows ">
        <label>银行卡号：</label>
        <input id="cardId" maxlength="19" onkeyup="this.value=this.value.replace(/\D/g,'')" type="number" class="mui-input-clear" placeholder="请输入银行卡号">
    </div>
    <div class="rows ">
        <label>真实姓名：</label>
        <input input id="truename" type="text" class="mui-input-clear" placeholder="请输入您的姓名">
    </div>
    <div class="rows ">
        <label>联系电话：</label>
        <input id="tel" type="number" class="mui-input-clear" placeholder="请输入联系电话">
    </div>

    <div id="post" class="button-simple" >提交申请</div>
    <div class="rows record">申请记录</div>

    <div class="table-warp">
        <table class="table">
            <thead>
                <tr style="height: 40px;">
                    <td>订单号</td>
                    <td>金额</td>
                    <td>时间</td>
                    <td>状态</td>
                </tr>
            </thead>
            <tbody>
                <volist name="list['applyList']" id="vo">
                    <tr class="border-bottom">
                        <td>{$vo.id}</td>
                        <td>&yen;{$vo.applyPrice}</td>
                        <td>{$vo.time||date="Y/m/d",###}</td>
                        <td class="{$vo['class']}">{$vo['status']}</td>
                    </tr>
                </volist>
            </tbody>
        </table>
    </div>
</div>
<script src="__JS__/jquery2.1.1.min.js"> </script>
<script src="__JS__/layer.min.js"> </script>
<script type="text/javascript">
function showBank(){
    $('#cover').fadeToggle('300');
    $('#bank').toggleClass('bank-active');
}

$('#bank>.rows,#cover').on('click',function(){
    showBank();
})

function selectBank(obj){
    $('.bank-orange').removeClass('bank-orange');
    $(obj).addClass('bank-orange');
    $('#bankName').html($(obj).text());
}


 $(function(){

    // $('#applyBalance').on('click',function(){
    //     if(!check.checkPrice()){
    //         layer.open({
    //             content: '余额为0转账',
    //             time: 2 //2秒后自动关闭
    //         });
    //         return;
    //     }
    //     check.sendBalance();

    // });

    $('#post').on('click',function(){


        for(var i in check){

            if(!check[i]()){
                layer.msg(check.error);
                // layer.open({
                //     content: check.error,
                //     time: 2 //2秒后自动关闭
                // });
                return;
            }
        }

    });

});


var check = {
    checkPrice:function(){
        this.price = $("#applyPrice").val();
        if(this.price<=0){
            this.error='请输入提现金额';
            return false;
        }
        return true;
    },
    checkOverflow:function(){
        this.price = $("#applyPrice").val();
        this.money = $("#money").html()*1.0;
        if(this.price<=0){
            this.error='请输入提现金额';
            return false;
        }
        if(this.price>this.money){
            this.error='申请金额需小于余额';
            return false;
        }
        return true;
    },
    checkbankName:function(){

        //this.bankName = $('#banks').val();
        //console.log($('#banks').val());
        // if(!this.bankName.length>0){
        //     this.error='请选择银行名称';
        //     return false;
        // }
        var $bk = $('.bank-orange');

        if($bk.length<1){
            this.error = '请选择银行';
            return false;
        }
         this.bankName = $bk.text();
        return true;
    },

    checknankAccess:function(){

        this.cardAccess=$.trim($('#cardAccess')[0].value);
        if(!this.cardAccess.length>0){
            this.error='请输入开户行地址';
            return false;
        }
        return true;
    },

    checkCardId:function(){
        this.cardId=$('#cardId')[0].value;
        if(!/^(\d{16}|\d{19})$/.test(this.cardId)){
            this.error='请输入正确的银行卡号';
            return false;
        }

        return true;

    },

    checkCradTrueName:function(){
        this.truename= $.trim($('#truename')[0].value);
        if(!this.truename.length>0){
            this.error='请输入开户人姓名';
            return false;
        }

        return true;
    },



    checkTel:function(){
        this.tel = $("#tel").val();

        if(!/^1[34578]\d{9}$/.test(this.tel)){
            this.error='请填写正确的手机号码';
            return false;
        }
        return true;

    },
    // checkPW:function(){
    //     this.Paypwd = $("#payPwd").val();
    //     if(this.Paypwd.length!=6){
    //         this.error='请填写六位数的支付密码';
    //         return false;
    //     }
    //     return true;
    //},
    send:function(){
        var index = layer.load(1, {
          shade: [0.5,'#000']
        });

        $.ajax({
            url:'/Home/Apply/apply',
            data:{
                bankUserName:this.truename,
                bankName:this.bankName,
                bankNum:this.cardId,
                bankAccess:this.cardAccess,
                applyPrice:this.price,
                tel:this.tel,
                applyType:0,
                payPwd:this.Paypwd
            },
            dataType: "json",
            type:"post",
            success:function(data){
                // console.log(data);
                // console.log(data.error);
                layer.closeAll(); //关闭加载层
                if(data.status==true){
                    layer.msg('申请成功,页面即将刷新');
                    setTimeout("location.reload();",2000);
                }else{
                    if(data['error']){
                        //this.error  =  data['error'];
                        layer.msg(data['error']);

                    }else{
                        this.error  =  '操作失败';
                        layer.msg(data['error']);
                    }
                    return false;
                }

            }
        });
        return true;
    }

};

</script>
</body>

</html>
